New in 1.2.1 – Dynamic Master Pages


RPE Master Pages are the means through which template designers control the layout of the document for the Word and PDF output. There is one aspect with design of the master pages that makes them harder to use, their properties are static.

This limitation can be overcome by using multiple master pages and toggling the use of one or the other though a variable, essentially allowing a dynamic master page usage in the template. The fundamental problem with this approach is that it requires duplication of the master pages.

RPE 1.2.1 removes this limitation and allows master pages to be fully dynamic. The outline of the typical process to use dynamic master pages is provided below.

A typical scenario where this capability is needed is to change the orientation of the page based on the value of an attribute from the data source, without changing any other property of the master page.

Prior to 1.2.1 the solution was to create master pages with “landscape” and “portrait” orientations but that would otherwise be identical.

With RPE 1.2.1 the solution is described below. The example template, data and the Word output are available here.

  1. create the master page as needed
  2. create an internal variable that controls the page orientation, for example pageOrientation_
  3. use this variable in the master page definition for the orientation property ( this was not previously possible) dynmp_3
  4. use this master page on the element where you want the switch to occur ( also see point 8 below)
    dynmp_1
  5. Calculate the orientation as needed. In my example I switch the master page to Landscape every time I encounter an object with Priority mandatory and change back to Portrait when any other object is found.
    dynmp_2

With the above steps the switch will only occur for the first time due to how RPE implements the master page switch: RPE switches the master page only if its name is different from the current page OR the force page change value is set to true.

Considering the above and since now a single master page is used you need to explicitly tell RPE when to change the page. This is done in a similar manner to how the orientation is calculated:

  1. create an internal variable that controls the page change, name it forcePageChange_
  2. calculate the value of this variable in the same place where you calculate the orientation, in item 3 above. Set it to true when the orientation has to change from Portrait to landscape and viceversa
  3. Use this variable as the value for the “force page change” property on the element where you have used the master page, item 4 above

Author: Dragos Cojocari

Architect for Rational Publishing Engine

6 thoughts on “New in 1.2.1 – Dynamic Master Pages”

  1. Hi Dragos. I’m looking for a way to create a Dynamic Master Page where I can use the content of a RDNG artifact as part of the header and footer. My goal is to select specific artifacts to be shown as header and footer so my users can modify those artifacts in a module and print a document with that modified artifacts. When trying to drag and drop

    1. Hey,

      you cannot use directly data queries in headers and footers. You need to assign the desired value to a variable and use that variable in the header and footer. See this for more details:

      Adding dynamic content to a master page: http://www-01.ibm.com/support/knowledgecenter/SS6RHZ_1.3.0/com.ibm.rational.pe.publishing.doc/topics/t_variables_master_pages.html
      Extracting Data in Master Page (GebsReporting): http://gebsreporting.com/blog/extracting-data-in-master-page/
      DevWorks thread: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014823411

      Regards,
      Dragos

      1. Hi Dragos… thanks a lot. After reviewing the links you provided and with a great help from people at developerWorks forum I finally got it. What I did was creating the variables and assigned the content of a DOORS NG artifact, it worked like a charm, I had some doubts because the content was a table with images on some cells, but it was not a problem.

        Thanks again and thanks for sharing your knowledge. Great blog for RPE users.

  2. Hello Dragos.
    Do you know if it’s possible to use the current page number as a Condition (preferably via JavaScript) in RPE?
    In my output there are things that should be depending on if the current page number is even or odd (similar to the orientation difference in this example, but depending on odd/even instead), but I have not found a way to find the current page number within Condition.

    Thanks in advance!
    Hampus

Leave a comment